package com.hz.motion;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.motion.widget.MotionLayout;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private boolean start = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final MotionLayout motionLayout = findViewById(R.id.container);
        final Button button = findViewById(R.id.bt);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (start) {
                    motionLayout.transitionToEnd();
                    button.setText("结束");
                } else {
                    motionLayout.transitionToStart();
                    button.setText("开始");
                }
                start = !start;
            }
        });
    }
}
